/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package samoloty.controler;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import samoloty.model.IDataModel;
import samoloty.view.MainWindow;
import samoloty.view.MyButton;
import samoloty.view.StartPanel;

/**
 *
 * @author frankowp
 */
public class StartPanelControler implements MyControler {

    private StartPanel panel;
    private Controler controler;
    private IDataModel dataModel;

    public StartPanelControler(Controler c) {
        controler = c;
        initPanel();
    }

    public StartPanelControler(Controler c, IDataModel data) {
        controler = c;
        dataModel = data;
        initPanel();
    }

    public StartPanel getPanel() {
        return panel;
    }

    public void initPanel() {
        panel = new StartPanel();
        panel.setOKactionListener(new OKbutton());


    }

    public void setUpWindow() {
        MainWindow window = controler.getView();

        window.setLeftPanelVisible(false);
        window.setRightPanelVisible(false);
        window.setExitVisible(true);
        firstFocused();
    }

    public void reset() {
        panel.reset();
    }

    public void okBtnAction() {
        controler.setMainPanel();
        controler.getView().setResetVisible(true);
        controler.getView().setHelpVisible(true);
        controler.getView().setFocusableComponents(true);
    }

    public void firstFocused() {
        panel.setFirstFocus();
    }

    private class OKbutton implements ActionListener {

        public void actionPerformed(ActionEvent e) {
            okBtnAction();
        }
    }

    public MyButton getExitBtn() {
        return controler.getView().getExitBtn();
    }
}
